//
// Created by mongobaba on 2021/6/8.
//

#include "unit_test.h"
#include "json_validator.h"

// 特殊情况
TEST(parse_element_empty) {
    json_validator validator("");
    ASSERT_EQ(false, validator.parse_element());
    ASSERT_EQ(std::string(""), validator.left());
}

// 前面有空白
TEST(parse_element_pre_whitespace) {
    json_validator validator(" 1x");
    ASSERT_EQ(true, validator.parse_element());
    ASSERT_EQ(std::string("x"), validator.left());
}

// 后面有空白
TEST(parse_element_post_whitespace) {
    json_validator validator("1 x");
    ASSERT_EQ(true, validator.parse_element());
    ASSERT_EQ(std::string("x"), validator.left());
}

// 前后都有空白
TEST(parse_element_both_whitespace) {
    json_validator validator(" 1 x");
    ASSERT_EQ(true, validator.parse_element());
    ASSERT_EQ(std::string("x"), validator.left());
}
